package com.hq.myvideo;


import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.fragment.app.Fragment;

import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;

public class PlayFullFragment extends Fragment {
    private static final String ARG_VIDEO_URL = "video_url";
    private StandardGSYVideoPlayer player = null;
    public String videoUrl;

    public static PlayFullFragment newInstance(String videoUrl) {
        PlayFullFragment fragment = new PlayFullFragment();
        Bundle args = new Bundle();
        args.putString(ARG_VIDEO_URL, videoUrl);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            this.videoUrl = getArguments().getString(ARG_VIDEO_URL);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.full_player_item, container, false);
        this.player = view.findViewById(R.id.vp);

        //增加title
        //  this.player.getTitleTextView().setVisibility(View.VISIBLE);
       // this.player.setSeekOnStart(833513);


        return view;
    }

    @Override
    public void onStart() {
        super.onStart();
        this.player.setUp(this.videoUrl, true, "p2滑动视频");
        Log.d("savedInstanceState", "onStart");

        this.player.startPlayLogic();
    }
    @Override
    public void onResume() {
        super.onResume();
        this.player.onVideoResume();
        Log.d("savedInstanceState", "onResume");
    }
    //is not authorized access iscsi portal group
    @Override
    public void onPause() {
        super.onPause();
        this.player.onVideoPause();
        Log.d("savedInstanceState", "onPause");
    }
    @Override
    public void onStop() {
        super.onStop();
        this.player.onVideoPause();
        Log.d("savedInstanceState", "onStop");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.player.setVideoAllCallBack(null);
        GSYVideoManager.releaseAllVideos();
        Log.d("savedInstanceState", "onDestroy");
    }
}
